/*
 * trace_traceStackInfo.c
 *
 *  Created on: 2012/06/06
 *      Author: guanxiaoying
 */
#include "../table.h"
#include "../trace_ast_table.h"
/*TRACE_STACKINFO	*/
typedef struct _TRACESTACKINFO
{
	U2	usKind;		/* 2 */
	UCHAR	usTimes;		/* 3 */
	UCHAR	usInLoopFlg;
	AST			astTable;		/* 4 	*/
	AST			astNext;	/* 7 */
	AST			astTraceSub;	/* 5 */
	AST			astParam[5];		/* 6 */
} TRACESTACKINFO, *PTRACESTACKINFO;

#define TableSize  (sizeof(TRACESTACKINFO ))
#define TableType  PTRACESTACKINFO
#define stTable stTraceStackInfoManager.memoryBlocks
#define maxTable stTraceStackInfoManager.maxRecordNum
#define  maxNumPerBlk  (stTraceStackInfoManager.astMaxNum_Block)


static TABLEMANAGER stTraceStackInfoManager = {
//		U4                  usIdx;
		0,
//		PSZ				    con_pszName;    constant
		__FILE__,
//		U2					con_usSize;		constant
		TableSize,
//		U2					block_num;	　　　　　　　Reset clear  際　要
		0,
//		S4					astMaxNum_Block;     １回設定のみ
		0,
//		S4					astTabNum_LastPage; 　　　　Reset clear  際　要
		0,
//		S4					astMaxNum_LastPage;     Reset clear  際　要
		0,
//		U4					ulMaxByte;	　　　　　　　　　　クリアしない
		0,
//		U4					con_minPageSize;　　　　　　　　　　constant
		0
};
static VOID resetListener( U4  procid, U2 index )
{
	if( procid == stTraceStackInfoManager.u4Idx )
	{
		if( index > 0 && index < MAX_VOLUMN_OF_TABLE )
		{
			stTable[ index-1] = NULL;
		}
	}
}
static TableType core_getTable( AST index )
{
	TableType temp = (TableType)Check_Com( &stTraceStackInfoManager, resetListener,  index );
	if( temp != NULL ){ return &temp[index%maxNumPerBlk]; } return NULL;
}
static BOOL ClearTable( VOID )
{
	return Clear_Com( &stTraceStackInfoManager );
}
static BOOL AllocTable( AST astReqArg )
{
	return AllocTable_Com( &stTraceStackInfoManager, astReqArg, resetListener );
}
static AST getMaxLineNum( VOID ){
	return maxTable;
}

static U2 getObjKind( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->usKind;
}
static U2 setObjKind( AST astIndex, U2 value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->usKind=value;
}
static U2 getTimes( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->usTimes;
}
static U2 setTimes( AST astIndex, U2 value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->usTimes=value;
}
static BOOL getLoopFlg( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->usInLoopFlg;
}
static BOOL setLoopFlg( AST astIndex, BOOL value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->usInLoopFlg=value;
}
static AST getCurrentObj( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astTable;
}
static AST setCurrentObj( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astTable=value;
}
static AST getNext( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astNext;
}
static AST setNext( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astNext=value;
}
static AST getCurrFunction( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astTraceSub;
}
static AST setCurrFunction( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astTraceSub=value;
}
static AST getParam1( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astParam[0];
}
static AST setParam1( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astParam[0]=value;
}

static AST getParam2( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astParam[1];
}
static AST setParam2( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astParam[1]=value;
}

static AST getParam3( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astParam[2];
}
static AST setParam3( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astParam[2]=value;
}

static AST getParam4( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astParam[3];
}
static AST setParam4( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astParam[3]=value;
}

static AST getParam5( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astParam[4];
}
static AST setParam5( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astParam[4]=value;
}
const TRACESTACKINFO_ACCESS stTraceStackAccess ={
		ClearTable,
		AllocTable,
		getMaxLineNum,
		{
				getObjKind,
				setObjKind
		},

		{
				getTimes,
				setTimes
		},
		{
				getLoopFlg,
				setLoopFlg
		},
		{
				getCurrentObj,
				setCurrentObj
		},
		{
				getNext,
				setNext
		},
		{
				getCurrFunction,
				setCurrFunction
		},
		{
				getParam1,
				setParam1
		},
		{
				getParam2,
				setParam2
		},
		{
				getParam3,
				setParam3
		},
		{
				getParam4,
				setParam4
		},
		{
				getParam5,
				setParam5
		}

};
